cmake_minimum_required(VERSION 3.5)

project(Qttest LANGUAGES CXX)

add_subdirectory(./cantest)
add_subdirectory(./handler2)
add_subdirectory(./openvpn)
add_subdirectory(./qttest)
add_subdirectory(./linux)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# QtCreator supports the following variables for Android, which are identical to qmake Android variables.
# Check http://doc.qt.io/qt-5/deployment-android.html for more information.
# They need to be set before the find_package(Qt5 ...) call.

#if(ANDROID)
#    set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
#    if (ANDROID_ABI STREQUAL "armeabi-v7a")
#        set(ANDROID_EXTRA_LIBS
#            ${CMAKE_CURRENT_SOURCE_DIR}/path/to/libcrypto.so
#            ${CMAKE_CURRENT_SOURCE_DIR}/path/to/libssl.so)
#    endif()
#endif()

find_package(Qt5 COMPONENTS Widgets REQUIRED)

if (ANDROID)
    add_library(
            Qttest
            SHARED
            main.cpp
            mainwindow.cpp
            mainwindow.h
            mainwindow.ui
    )
else ()
    add_executable(
            Qttest

            #[[main]]
            main.cpp
            mainwindow.cpp
            mainwindow.h
            mainwindow.ui

            #[[cantest]]
            cantest/open/OpenCan.h
            cantest/comm/CommunityCan.h

            #[[handler2]]
            handler2/CxxHandler.h
            handler2/ThreadPool.h

            #[[openvpn]]
            openvpn/config/VpnConfig.h
            openvpn/connection/VpnConnection.h
            openvpn/server/VpnProxyServer.h
            openvpn/log/VpnLog.h

            #[[qttest]]
            qttest/signal/QtSignalTest.h
            qttest/signal/QtSignal.h
            qttest/layout/LayoutWindow.h
            qttest/layout/edit/LineEdit.h
            qttest/layout/button/Buttons.h
            qttest/layout/button/ComboBox.h
            qttest/layout/listview/ListView.h
            qttest/layout/listview/TreeView.h
            qttest/dialog/MyCustomDialog.h

            #[[linux-file]]
            linux/file/file_syscall.h
    )
endif ()

target_link_libraries(
        Qttest
        PRIVATE
        pthread
        Qt5::Widgets
        cantest
        openvpn
        qttest
        handler2
        linux-file
        linux-memory
        cxx_seq_container
        order_container
        unorder_container
        container_adapter
        unmodify_algorithm
        modify_algorithm
        find_sort_algorithm
        MaxMinValue
        ItrOverview
        ItrAdapter
        RangeFunc
        FuncObj
        FuncAdapter
        PseudoCont
        SmartPtr
        StlAllocator
)
